<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>role -- resource</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<script type="text/javascript" src="DivTree.js"></script>
		<script type="text/javascript" src="Tree.js"></script>
		<script type="text/javascript" src="Node.js"></script>
		<script type="text/javascript" src="mootools.js"></script>
		<link rel="StyleSheet" href="resource/css/default.css" type="text/css" />
		<style type="text/css">
		body{
			background-color: #F9F8E8;
			font-family: arial;
			font-size: 12px;
		}
		
		tr{
			background-color: #F9F8E8;
		}
		a{
			font-size: 12px;
			font-family: arial;
			color: green;
		}
		a hover{
			
		}
		a HOVER {
			color: red;
		}
		a VISITED {
			color: gray;
		}
		a FOCUS {
			color: yellow;
		}
		.table_role{
			width:360px;
			font-size: 12px;
			font-family: arial;
			background-color: #000000;
		}
	</style>
	</head>
	<script type="text/javascript">
  	var cur_role = 0;
  	var cur_row = null;
  	var resourceTree = null;
  	function changeRole(rid,roww){
  		if(resourceTree == null) return;
  		$('prompt_info').innerHTML = "��������ִ��...";
  		if(cur_row != null){
			cur_row.style.backgroundColor = "#F9F8E8";
  		}
		roww.style.backgroundColor = "#EEE999";
		cur_role = rid;
		cur_row = roww;
		//���ͽ�ɫID����̨����ѯ����ɫ�Ѿ��е���Դ
		var paras = "action=query&roleId=" + rid;
		new Ajax("roleResourceAction.do",{postBody:paras,onComplete:getRoleResources,encoding:'UTF-8'}).request();
		resourceTree.initReset()
  	}
  	function getRoleResources(request){
  		var arr = resourceTree.tree.treeArray;
  		if(request != null && request != "null"){
  			var rids = request.split(",");
  			resourceTree.expandTree();
  			for(var i = 0;i<rids.length;i++){
  				var node  = findNode(arr,rids[i]);//�õ��ڵ�
				if(node){
					var nele = node.getHtmlElementfuxuanimg();
					if(nele == null){
						alert("NOT FOUND:" + rids[i] + "NODE: " + node);
					}else{
						nele.selected();
					}
				}
  			}
  			resourceTree.initTreeForm();
  		}
  		$('prompt_info').innerHTML = "����ִ�гɹ���";
  	}
  	 function findNode(arr,sid) {
	  for(var i=0;i<arr.length;i++){
	    if(arr[i].id != null && arr[i].id != undefined && arr[i].id != ""){
	      if(parseInt(arr[i].id) == parseInt(sid)){
	        return arr[i];
	      }
	     }
	  }
	  return null;
	}
  	function treeMethod1(){
  	}
  	function treeMethod2(){
  	}
  	
  	function mOvr(roww) {
		roww.style.cursor = "hand";
		if(roww != cur_row){
			roww.style.backgroundColor = "#FFF8C5";
		}
	}
	function mOut(roww) {
		roww.style.cursor = "default";
		roww.style.backgroundColor = "#F9F8E8";
		if(cur_row != null){
			cur_row.style.backgroundColor = "#EEE999";
		}
	}
	function saveResource(){
		$('prompt_info').innerHTML = "��������ִ��...";
		$("err_msg_apsn").innerHTML = "";
		if(cur_role == 0){
			$("err_msg_apsn").innerHTML = "��ѡ��һ�����Ա��";
			return;
		}
		var allNodes =resourceTree.getNodesAll();
		var isstring = "";
  		if(allNodes.length>0){
  			for(var i = 0;i<allNodes.length;i++){
  				isstring += "," + allNodes[i].id;
  			}
  			isstring = isstring.substring(1);
  			var paras = "action=save&roleId=" + cur_role + "&idstring=" + isstring;
  			new Ajax("roleResourceAction.do",{postBody:paras,onComplete:getRoleResources,encoding:'UTF-8'}).request();
  		}else{
  			var paras = "action=save&roleId=" + cur_role + "&idstring=";
  			new Ajax("roleResourceAction.do",{postBody:paras,onComplete:getRoleResources,encoding:'UTF-8'}).request();
  		}
	}
  </script>
	
	
	<body><br>
		<h4 style=" color: #123234">
			Role and resources relationship operation page.
		</h4>
		<br>
		<table width="800">
			<tr>
				<td valign="top" width="400">
					<b>Roles list:</b>
					<br>
					<br>
					<table cellspacing="1" cellpadding="3" class="table_role">
						<tr>
							<td>
								<span class="role_th">Role name</span>
							</td>
							<td>
								<span class="role_th">Role code</span>
							</td>
							<td>
								<span class="role_th">Organization</span>
							</td>
						</tr>
						
						<tr onclick="changeRole(1,this);" onmouseover="mOvr(this);" onmouseout="mOut(this);">
							<td>
								super manager
							</td>
							<td>
								super
							</td>
							<td>
								javawas
							</td>
						</tr>
						
					</table>
				</td>
				

				<td valign="top" width="400">
					<span class="role_th">Right tree and Resources of had right.</span>
					<br>
					<br>
					<!-- �����Դ�� -->
					<script type="text/javascript">
    		//������ʹ������ռ�
			//var allResources = new xyTree.DivTree('������Դ');
			//5����ʱ��
			var node1,node2,node3,node4,node5,node6;
			var resourceTree = new xyTree.DivTree('EEWAS');
node1 = new xyTree.Node('ϵͳ���Ĺ���');
node1.id=185;
resourceTree.add(node1);
node2 = new xyTree.Node('�������');
node2.id=186;
node1.add(node2);
node3 = new xyTree.Node('���л���');
node3.id=187;
node2.add(node3);
node3 = new xyTree.Node('DB Config');
node3.id=188;
node2.add(node3);
node3 = new xyTree.Node('Grid Config');
node3.id=203;
node2.add(node3);
node3 = new xyTree.Node('Window Config');
node3.id=214;
node2.add(node3);
node2 = new xyTree.Node('Ȩ�޹���');
node2.id=190;
node1.add(node2);
node3 = new xyTree.Node('�û���ɫ����');
node3.id=191;
node2.add(node3);
node3 = new xyTree.Node('��ɫ��Դ����');
node3.id=192;
node2.add(node3);
node3 = new xyTree.Node('��ɫ����');
node3.id=193;
node2.add(node3);
node3 = new xyTree.Node('�û�����');
node3.id=194;
node2.add(node3);
node2 = new xyTree.Node('ϵͳ���б���');
node2.id=204;
node1.add(node2);
node3 = new xyTree.Node('ϵͳ�쳣��');
node3.id=205;
node2.add(node3);
node3 = new xyTree.Node('�ʼ����͹���');
node3.id=206;
node2.add(node3);
node3 = new xyTree.Node('�Ƿ�������־');
node3.id=207;
node2.add(node3);
node1 = new xyTree.Node('��վ����');
node1.id=198;
resourceTree.add(node1);
node2 = new xyTree.Node('�û���¼���');
node2.id=202;
node1.add(node2);
node2 = new xyTree.Node('ϵͳ����ͳ��');
node2.id=209;
node1.add(node2);
node1 = new xyTree.Node('����');
node1.id=212;
resourceTree.add(node1);
node2 = new xyTree.Node('�û�����');
node2.id=213;
node1.add(node2);
node2 = new xyTree.Node('�û���ַ');
node2.id=215;
node1.add(node2);

    		</script>
					<div id="rigth_tree">

					</div>
					<!-- ��ʼ����Դ�� -->
					<script type="text/javascript">
    			document.getElementById('rigth_tree').appendChild(resourceTree.div);
  				resourceTree.init(treeMethod1, treeMethod2); //�����Զ���ص���
    		</script>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<span id="prompt_info" style="padding-left: 77px"></span>
					<br>
					<span style="padding-left: 237px"><input type="button" value="save resources" onclick="saveResource();"/></span>
					<span style="color: red;font-size: 12px;padding-left: 37px;font-weight: bold;" id="err_msg_apsn"></span>
		</table>
	</body>
</html>
